package com.douqu.game.battle.entity.tmp;

import com.douqu.game.battle.controller.sprite.MonsterController;
import com.douqu.game.core.config.challenge.WorldBossParameterConfig;
import com.douqu.game.core.config.map.CityArmyGroupConfig;
import com.douqu.game.core.factory.ConstantFactory;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.protobuf.SGCommonProto;
import com.douqu.game.core.util.CoreUtils;


/**
 * Created by bean on 2017/9/13.
 */
public class MonsterBattleTmp extends SpriteBattleTmp {



    @Override
    public SGCommonProto.PlayerBaseInfo parseBaseInfo(String... names)
    {
        SGCommonProto.PlayerBaseInfo.Builder baseInfo = SGCommonProto.PlayerBaseInfo.newBuilder();
        baseInfo.setNickName((names.length==0|| CoreUtils.isNullOrEmpty(names[0])) ? spriteController.getName() : names[0]);

        MonsterController monsterController = (MonsterController) spriteController;
        if(monsterController.getMasterConfig() != null)
        {
            baseInfo.setAvatar(monsterController.getMasterConfig().id+"");
            baseInfo.setCamptypeValue(monsterController.getMasterConfig().camp);
        }

        if(battleController.getBattleType() == SGCommonProto.E_BATTLE_TYPE.BATTLE_TYPE_WORLD_BOSS)
        {
            WorldBossParameterConfig worldBossParameterConfig = DataFactory.getInstance().getGameObject(DataFactory.WORLD_BOSS_PARAM_KEY, lv);
            if(worldBossParameterConfig == null)
                worldBossParameterConfig = (WorldBossParameterConfig) DataFactory.getInstance().getDataList(DataFactory.WORLD_BOSS_PARAM_KEY).get(0);
            baseInfo.setFc(worldBossParameterConfig.fc);
        }
        else if(battleController.getBattleType() == SGCommonProto.E_BATTLE_TYPE.BATTLE_TYPE_WORLD_MAP)
        {
            String[] params = battleController.getTargetData().split(ConstantFactory.UNDERLINE);
            CityArmyGroupConfig cityArmyGroupConfig = DataFactory.getInstance().getGameObject(DataFactory.CITY_ARMY_GROUP_KEY, Integer.parseInt(params[1]));
            baseInfo.setFc(cityArmyGroupConfig.fc);
        }
        else
        {
            if(monsterController.getBattleInitConfig() != null)
                baseInfo.setFc(monsterController.getBattleInitConfig().fc);
        }

        baseInfo.setLv(lv);
        baseInfo.setVipLv(0);

        return baseInfo.build();
    }

    @Override
    public String getSpriteObjectIndex()
    {
        return null;
    }


}
